package cn.xzqwjw.taskmanager.domain.vo;

import lombok.Data;
import org.springframework.stereotype.Component;

import java.awt.*;
import java.time.LocalDateTime;
import java.util.Random;

/**
 * 验证码Vo
 *
 * @author rush
 */
@Data
@Component
public class VerifyCodeVo {

  private int imageWidth = 70;

  private int imageHeight = 35;

  private Random random = new Random();

  /**
   * {"宋体", "华文楷体", "黑体", "华文新魏", "华文隶书", "微软雅黑", "楷体_GB2312"}
   */
  private String[] fontNames = {"宋体", "华文楷体", "黑体", "微软雅黑", "楷体_GB2312"};

  /**
   * 可选字符
   */
  private String codes = "123456789abcdefghjkmnpqrstuvwxyzABCDEFGHJKMNPQRSTUVWXYZ";

  /**
   * 背景色
   */
  private Color bgColor = new Color(255, 255, 255);

  /**
   * 验证码上的文本
   */
  private String text;

  /**
   * 设置过期的秒数
   */
  private int expiredSecond = 60;

  /**
   * 过期时间
   */
  private LocalDateTime dtExpired = LocalDateTime.now().plusSeconds(expiredSecond);

  /**
   * 判断是否过期
   */
  public boolean isExpired() {
    return LocalDateTime.now().isAfter(dtExpired);
  }

}
